*** Variables ***
${url}            http://127.0.0.1
${port}           5000

*** Keywords ***
selectOne
    [Arguments]    ${id}
    &{dict}    Create Dictionary    id=${id}
    Create Session    api    ${url}:${port}
    ${result}=    Get On Session    api    url=/selectOne    params=&{dict}
    Dictionary Should Contain Key    ${result.json()}    code
    Should Be Equal    ${result.json().get("code")}    ${200}
    log    ${result.json().get("code")}

add
    [Arguments]    ${id}    ${name}    ${age}
    &{dict}    Create Dictionary    id=${id}    name=${name}    age=${age}
    Create Session    api    ${url}:${port}
    ${result}=    Get On Session    api    url=/add    params=&{dict}
    Dictionary Should Contain Key    ${result.json()}    code
    Should Be Equal    ${result.json().get("code")}    ${200}
    log    ${result.json().get("code")}

modify
    [Arguments]    ${id}    ${name}    ${age}
    &{dict}    Create Dictionary    id=${id}    name=${name}    age=${age}
    Create Session    api    ${url}:${port}
    ${result}=    Get On Session    api    url=/modify    params=&{dict}
    Dictionary Should Contain Key    ${result.json()}    code
    Should Be Equal    ${result.json().get("code")}    ${200}
    log    ${result.json().get("code")}

delete
    [Arguments]    ${id}
    &{dict}    Create Dictionary    id=${id}
    Create Session    api    ${url}:${port}
    ${result}=    Get On Session    api    url=/delete    params=&{dict}
    Dictionary Should Contain Key    ${result.json()}    code
    Should Be Equal    ${result.json().get("code")}    ${200}
    log    ${result.json().get("code")}
